#!/bin/bash

# learn linux shell

echo 'hello world'
if pwd
then
	echo 'ped succ'
fi

testuser=penghk
if grep $testuser /etc/passwd;then
	echo 'this is my first command'
fi

testvar="hello"
if test $testvar;then
	echo "test succ"
else
	echo "test fail"
fi

var=""
if [ $var1 ];then
	echo 'ok'
else
	echo 'fail'
fi

var2=10
if [ $var2 -gt 5 ];then
	echo "var2 is greater than 5"
fi
echo "------------------------------"
var3=testing
var4=''
if [ -n $var3 ];then
	echo "the string '$var3' is not empty"
fi
if [ -z $var4 ];then
	echo "the string is empty"
fi

echo "------------------------------------"
desDir=/home/penghk
if [ -d $desDir ];then
	ls -l $desDir
fi

echo "--------------------------------------"
item_name=$HOME
if [ -e $item_name ];then
	echo " '$item_name' is exist"
	if [ -f $item_name ];then
		echo " $item_name is a file"
	else
		echo " $item_name is not a file"
	fi
fi
























